<?php
/**
 * Description of index
 * 
 * @author anhducbkhn
 * @since Oct 14, 2013 - 4:26:01 PM
 */
?>
<div class="row-fluid">
    <div class="box span12">
        <div class="box-header">
            <h2><i class="icon-cogs"></i><span class="break"></span>
                Hotdeal
            </h2>         
        </div>
        <div class="box-content">
            <?
            //register css file
            Yii::app()->clientScript->registerCssFile($this->assetDir . 'css/kdt/user.css');
            ?>
            <?php if (!$services): ?>
                <div class="box-content alerts">
                    <div class="alert alert-error">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        Sorry, there are no Hotdeal service or class.
                    </div>
                </div>
            <?php else: ?>
                <?php if (Yii::app()->user->hasFlash('success')): ?>
                    <div class="alert alert-success">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>All done!</strong> <?php echo Yii::app()->user->getFlash('success'); ?>
                    </div>
                <?php endif; ?>
                <div class="pull-left">
                    <h2><span class="badge badge-info">Services</span></h2>
                </div>
                <div class="pull-right">
                    <p>
                        <a href="<?php echo Yii::app()->createUrl('hotdeal/list') ?>" class="btn btn-primary">
                            <i class="icon-plus"></i> Add hotdeal
                        </a>
                    </p>
                </div>
                <div class="clearfix"></div>
                <div class="table-responsive"> 
                    <table class="table table-bordered table-striped table-condensed">
                        <thead>
                            <tr>
                                <th>Name service</th>
                                <th>Price</th>
                                <th>Biz Owner</th>
                                <th>Hotdeal Status</th>
                                <th>Edit</th>

                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($services as $sv): ?>
                                <tr>
                                    <td>
                                        <a class="quick-detail" data-rel="popover"
                                           data-html="true" data-delay="1" data-trigger="click"
                                           data-content='<?php
                                           echo $this->renderPartial('/service/_quick_detail', array(
                                               'sv' => $sv->service
                                           ));
                                           ?>' >
                                               <?php echo $sv->service->s_name; ?>
                                        </a>
                                    </td>
                                    <td>$<?php echo $sv->special_price; ?></td>
                                    <td>
                                        <a href="<?php echo $sv->service->user->editUrl ?>">
                                            <?php echo $sv->service->user->name; ?>
                                        </a>
                                    </td>
                                    <td>
                                        <?php if ($sv->merchant_status == Hotdeal::MERCHANT_ACTIVE): ?>
                                            <span class="label badge-success"><?php echo Hotdeal::MERCHANT_ACTIVE; ?></span>
                                        <?php else: ?>
                                            <span class="label label-important"><?php echo Hotdeal::MERCHANT_BLOCK; ?></span>
                                        <?php endif; ?>

                                    </td>
                                    <td class="center">
                                        <a href="<?php echo Yii::app()->createUrl('hotdeal/modify', array('sv' => $sv->sid)) ?>"class="btn btn-success">
                                            <i class="icon-edit "></i></a>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
                <div class="pagination pagination-centered clearfix">
                    <?php
                    $this->widget('application.widgets.MyLinkPager', array(
                        'actionPrefix'         => 'service',
                        'pages'                => $pages,
                        'header'               => '',
                        'maxButtonCount'       => 5,
                        'nextPageLabel'        => '&raquo;',
                        'firstPageLabel'       => '←',
                        'lastPageLabel'        => '→',
                        'prevPageLabel'        => '&laquo;',
                        'selectedPageCssClass' => 'active',
                    ))
                    ?>
                </div>
                <!--Class-->
                <h2><span class="badge badge-warning">Classes</span></h2>
                <div class="table-responsive"> 
                    <table class="table table-bordered table-striped table-condensed">
                        <thead>
                            <tr>
                                <th>Name service</th>
                                <th>Date</th>
                                <th>Slots status</th>
                                <th>Biz Owner</th>
                                <th>Hotdeal Status</th>
                                <th>Edit</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($classes as $class): ?>
                                <tr>
                                    <td>
                                        <a class="quick-detail" data-rel="popover"
                                           data-html="true" data-delay="1" data-trigger="click"
                                           data-content='<?php
                                           echo $this->renderPartial('/service/_quick_detail', array(
                                               'sv' => $class->appoint->service
                                           ));
                                           ?>' >
                                               <?php echo $class->appoint->service->s_name; ?>
                                        </a>
                                    </td>
                                    <td><?php echo $class->appoint->formatDate(); ?>, <?php echo $class->appoint->startTime ?></td>
                                    <td><span class="badge badge-success"><b><?php echo $class->appoint->getCustomersize() ?></b></span></td>
                                    <td>
                                        <a href="<?php echo $class->appoint->service->user->editUrl ?>">
                                            <?php echo $class->appoint->service->user->name; ?>
                                        </a>
                                    </td>
                                    <td>
                                        <?php if ($class->merchant_status == Hotdeal::MERCHANT_ACTIVE): ?>
                                            <span class="label badge-success"><?php echo Hotdeal::MERCHANT_ACTIVE; ?></span>
                                        <?php else: ?>
                                            <span class="label label-important"><?php echo Hotdeal::MERCHANT_BLOCK; ?></span>
                                        <?php endif; ?>

                                    </td>
                                    <td class="center">
                                        <a href="<?php echo Yii::app()->createUrl('hotdeal/modify', array('class' => $class->apt_id)) ?>"class="btn btn-success">
                                            <i class="icon-edit "></i></a>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
                <div class="pagination pagination-centered clearfix">
                    <?php
                    $this->widget('application.widgets.MyLinkPager', array(
                        'actionPrefix'         => 'class',
                        'pages'                => $pages_classes,
                        'header'               => '',
                        'maxButtonCount'       => 5,
                        'nextPageLabel'        => '&raquo;',
                        'firstPageLabel'       => '←',
                        'lastPageLabel'        => '→',
                        'prevPageLabel'        => '&laquo;',
                        'selectedPageCssClass' => 'active',
                    ))
                    ?>
                </div>
                <div class="clearfix"></div>
            <?php endif; ?>
        </div>
    </div>
</div>